# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

pkgname=ebook-tools
pkgver=0.2.2
pkgrel=7
pkgdesc="Tools for accessing and converting various ebook file formats"
arch=(x86_64)
url="https://sourceforge.net/projects/ebook-tools/"
license=(custom)
depends=(libzip libxml2 convertlit)
makedepends=(cmake)
source=("https://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        crash-fix.patch)
sha256sums=('cbc35996e911144fa62925366ad6a6212d6af2588f1e39075954973bbee627ae'
            'ad556ce08909727a6022c9f1632086ccb8623a81a4f39cd34722e22116e14527')

prepare() {
  mkdir -p build

  cd $pkgname-$pkgver
  patch -p2 -i ../crash-fix.patch # https://sourceforge.net/p/ebook-tools/bugs/8/
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_INSTALL_PREFIX=/usr
  make
}

package() {
  cd build
  make DESTDIR="$pkgdir" install

  install -Dm644 "$srcdir"/$pkgname-$pkgver/LICENSE \
    -t "$pkgdir"/usr/share/licenses/$pkgname/
}
